package cn.com.spotty.springdemo.controller;

import cn.com.spotty.springdemo.bean.News;
import cn.com.spotty.springdemo.services.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
@Controller
public class MybatisController {
	@Autowired
	NewsService newsService;

	@RequestMapping(value = "/mybatis", method = RequestMethod.GET)
	public String index(Model model) {
		List<News> newsList = newsService.getNews();
		model.addAttribute("news", newsList);
		return "mybatis";
	}
}
